package com.scut.online_black_market.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scut.online_black_market.dto.ErrandResponse;
import com.scut.online_black_market.entity.ErrandTask;
import org.apache.ibatis.annotations.Select;

public interface ErrandTaskMapper extends BaseMapper<ErrandTask> {

    @Select("select errand_id,start_place,end_place,weight, " +
            "       end_time,price,note,nickname,picture_address, " +
            "       campus from personal join errand_task et " +
            "           on personal.student_number = et.proposer_number and et.state = 1")
    IPage<ErrandResponse> selectType1(IPage<?> page);

    @Select("select errand_id,start_place,end_place,weight, " +
            "       end_time,price,note,nickname,picture_address, " +
            "       campus from personal join errand_task et " +
            "           on personal.student_number = et.proposer_number" +
            " where personal.campus = \"南校\" and et.state = 1")
    IPage<ErrandResponse> selectType2(IPage<?> page);

    @Select("select errand_id,start_place,end_place,weight, " +
            "       end_time,price,note,nickname,picture_address, " +
            "       campus from personal join errand_task et " +
            "           on personal.student_number = et.proposer_number" +
            " where personal.campus =\"北校\" and et.state = 1")
    IPage<ErrandResponse> selectType3(IPage<?> page);

    @Select("select errand_id,start_place,end_place,weight, " +
            "       end_time,price,note,nickname,picture_address, " +
            "       campus from personal join errand_task et " +
            "           on personal.student_number = et.proposer_number" +
            " where et.state = 1 order by price")
    IPage<ErrandResponse> selectType4(IPage<?> page);

    @Select("select errand_id,start_place,end_place,weight, " +
            "       end_time,price,note,nickname,picture_address, " +
            "       campus from personal join errand_task et " +
            "           on personal.student_number = et.proposer_number" +
            " where et.state = 1 order by price DESC")
    IPage<ErrandResponse> selectType5(IPage<?> page);

}
